<!DOCTYPE html>
{% load static %}
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>录入指纹 - 实验室门禁系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
    <style>
        :root {
            --primary-color: #4a6cf7;
            --secondary-color: #6c757d;
            --success-color: #28a745;
            --danger-color: #dc3545;
            --light-color: #f8f9fa;
            --dark-color: #343a40;
            --border-radius: 8px;
            --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
            background-color: #f5f7fb;
            color: #333;
            line-height: 1.6;
            padding: 0;
            margin: 0;
        }
        
        .sidebar {
            min-height: 100vh;
            background: linear-gradient(180deg, var(--primary-color) 10%, #224abe 100%);
            color: white;
            position: fixed;
            width: 250px;
        }
        
        .sidebar .nav-link {
            color: rgba(255, 255, 255, 0.8);
            padding: 1rem;
            transition: all 0.2s;
        }
        
        .sidebar .nav-link:hover {
            color: white;
            background-color: rgba(255, 255, 255, 0.1);
        }
        
        .sidebar .nav-link.active {
            color: white;
            font-weight: bold;
        }
        
        .sidebar .sidebar-brand {
            height: 4.375rem;
            text-decoration: none;
            font-size: 1.2rem;
            font-weight: 800;
            padding: 1.5rem 1rem;
            text-align: center;
            letter-spacing: 0.05rem;
            color: white;
        }
        
        .main-content {
            margin-left: 250px;
            padding: 1.5rem;
        }
        
        .user-info {
            padding: 1rem;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            margin-bottom: 1rem;
        }
        
        .user-info .user-name {
            font-weight: bold;
            font-size: 1.1rem;
        }
        
        .container {
            max-width: 800px;
            margin: 40px auto;
            padding: 20px;
        }
        
        .card {
            background: white;
            border-radius: var(--border-radius);
            box-shadow: var(--box-shadow);
            padding: 30px;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            animation: cardSlideIn 0.5s ease-out;
        }
        
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
        }
        
        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }
        
        .header h1 {
            font-size: 24px;
            color: var(--dark-color);
        }
        
        .back-button {
            background: var(--light-color);
            color: var(--dark-color);
            border: none;
            padding: 8px 15px;
            border-radius: var(--border-radius);
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s ease;
            text-decoration: none;
            display: inline-block;
        }
        
        .back-button:hover {
            background: #e2e6ea;
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: var(--dark-color);
        }
        
        input[type="text"] {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: var(--border-radius);
            font-size: 16px;
            transition: border-color 0.3s, box-shadow 0.3s;
        }
        
        input[type="text"]:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.2);
            outline: none;
        }
        
        .submit-button {
            background: linear-gradient(135deg, #4a6cf7 0%, #5e81f4 100%);
            color: white;
            border: none;
            padding: 12px 20px;
            border-radius: var(--border-radius);
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s ease;
            width: 100%;
            font-size: 16px;
            margin-top: 10px;
        }
        
        .submit-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(74, 108, 247, 0.3);
        }
        
        .alert {
            padding: 15px;
            border-radius: var(--border-radius);
            margin-bottom: 20px;
            font-weight: 500;
        }
        
        .alert-success {
            background-color: rgba(40, 167, 69, 0.1);
            border: 1px solid rgba(40, 167, 69, 0.2);
            color: var(--success-color);
        }
        
        .alert-danger {
            background-color: rgba(220, 53, 69, 0.1);
            border: 1px solid rgba(220, 53, 69, 0.2);
            color: var(--danger-color);
        }
        
        .card-animation {
            animation: cardSlideIn 0.5s ease-out;
        }
        
        .fingerprint-container {
            display: flex;
            justify-content: center;
            margin: 20px 0;
        }
        
        .fingerprint-icon {
            width: 120px;
            height: 120px;
            background-color: rgba(74, 108, 247, 0.1);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 20px;
            position: relative;
            overflow: hidden;
        }
        
        .fingerprint-icon i {
            font-size: 60px;
            color: var(--primary-color);
        }
        
        .fingerprint-status {
            text-align: center;
            font-weight: 500;
            margin-bottom: 20px;
            color: var(--secondary-color);
        }
        
        .fingerprint-animation {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: radial-gradient(circle, rgba(74, 108, 247, 0.2) 0%, rgba(74, 108, 247, 0) 70%);
            opacity: 0;
        }
        
        @keyframes cardSlideIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        @keyframes pulse {
            0% {
                transform: scale(0.95);
                opacity: 0.7;
            }
            50% {
                transform: scale(1.05);
                opacity: 0.3;
            }
            100% {
                transform: scale(0.95);
                opacity: 0.7;
            }
        }
        
        .steps-container {
            margin: 30px 0;
        }
        
        .step {
            display: flex;
            margin-bottom: 15px;
            align-items: flex-start;
        }
        
        .step-number {
            width: 30px;
            height: 30px;
            background-color: var(--primary-color);
            color: white;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: bold;
            margin-right: 15px;
            flex-shrink: 0;
        }
        
        .step-content {
            flex: 1;
        }
        
        .step-title {
            font-weight: 600;
            margin-bottom: 5px;
            color: var(--dark-color);
        }
        
        .step-description {
            color: var(--secondary-color);
            font-size: 14px;
        }
    </style>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body>
    <!-- 侧边栏 -->
    <div class="sidebar">
        <a href="#" class="sidebar-brand">
            <i class="bi bi-shield-lock"></i> 实验室门禁系统
        </a>
        
        <div class="user-info">
            <div class="user-name">{{ username }}</div>
            <small>欢迎回来</small>
        </div>
        
        <ul class="nav flex-column">
            <li class="nav-item">
                <a class="nav-link" href="{% url 'back:dashboard' %}">
                    <i class="bi bi-speedometer2 me-2"></i> 控制面板
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="{% url 'back:write_card' %}">
                    <i class="bi bi-credit-card me-2"></i> 卡片录入
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link active" href="{% url 'back:write_finger' %}">
                    <i class="bi bi-fingerprint me-2"></i> 指纹录入
                </a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="{% url 'back:write_password' %}">
                    <i class="bi bi-key me-2"></i> 密码设置
                </a>
            </li>
            <li class="nav-item mt-5">
                <a class="nav-link" href="{% url 'back:logout' %}">
                    <i class="bi bi-box-arrow-right me-2"></i> 退出登录
                </a>
            </li>
        </ul>
    </div>
    
    <!-- 主内容区 -->
    <div class="main-content">
        <div class="container">
            <div class="card card-animation">
                <div class="header">
                    <h1>录入指纹</h1>
                    <a href="{% url 'back:dashboard' %}" class="back-button">返回仪表盘</a>
                </div>
                
                {% if success %}
                <div class="alert alert-success">
                    {{ success }}
                </div>
                {% endif %}
                
                {% if error %}
                <div class="alert alert-danger">
                    {{ error }}
                </div>
                {% endif %}
                
                <div class="fingerprint-container">
                    <div>
                        <div class="fingerprint-icon">
                            <i class="fas fa-fingerprint"></i>
                            <div class="fingerprint-animation" id="fingerprintAnimation"></div>
                        </div>
                        <div class="fingerprint-status" id="fingerprintStatus">准备录入指纹</div>
                    </div>
                </div>
                
                <div class="steps-container">
                    <div class="step">
                        <div class="step-number">1</div>
                        <div class="step-content">
                            <div class="step-title">输入用户信息</div>
                            <div class="step-description">填写用户ID和姓名，用于识别指纹所有者</div>
                        </div>
                    </div>
                    
                    <div class="step">
                        <div class="step-number">2</div>
                        <div class="step-content">
                            <div class="step-title">点击开始录入</div>
                            <div class="step-description">点击提交按钮，系统将准备录入指纹</div>
                        </div>
                    </div>
                    
                    <div class="step">
                        <div class="step-number">3</div>
                        <div class="step-content">
                            <div class="step-title">按压指纹传感器</div>
                            <div class="step-description">请将手指放在指纹传感器上，按照提示完成录入</div>
                        </div>
                    </div>
                </div>
                
                <form method="post" id="fingerprintForm">
                    {% csrf_token %}
                    <div class="form-group">
                        <label for="user_id">用户ID</label>
                        <input type="text" id="user_id" name="user_id" required placeholder="请输入用户ID">
                    </div>
                    
                    <div class="form-group">
                        <label for="user_name">用户姓名</label>
                        <input type="text" id="user_name" name="user_name" required placeholder="请输入用户姓名">
                    </div>
                    
                    <button type="submit" class="submit-button" id="submitBtn">开始录入指纹</button>
                </form>
            </div>
        </div>
    </div>
    
    <script>
        const form = document.getElementById('fingerprintForm');
        const fingerprintStatus = document.getElementById('fingerprintStatus');
        const fingerprintAnimation = document.getElementById('fingerprintAnimation');
        const submitBtn = document.getElementById('submitBtn');
        
        form.addEventListener('submit', function(e) {
            // 不阻止表单提交，但添加动画效果
            fingerprintStatus.textContent = '正在录入指纹，请将手指放在传感器上...';
            fingerprintAnimation.style.animation = 'pulse 1.5s infinite';
            fingerprintAnimation.style.opacity = '1';
            submitBtn.disabled = true;
            submitBtn.textContent = '录入中...';
            
            // 这里不阻止表单提交，让后端处理
            // 如果需要AJAX提交，可以在这里添加代码
        });
    </script>
</body>
</html>